package com.fjp.heartguard.ui.report.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.fjp.heartguard.ui.report.ReportAllFragment
import com.fjp.heartguard.ui.report.ReportLocalFragment
import com.fjp.heartguard.ui.report.ReportMineFragment

/**
 *Author:Mr'x
 *Time:2025/1/9
 *Description:
 */
class ReportFragmentPagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm) {
    private val fragments = arrayListOf<Fragment>(ReportMineFragment(), ReportAllFragment())

    override fun getCount(): Int {
        return fragments.size
    }

    override fun getItem(position: Int): Fragment {
        return fragments[position]
    }

   fun addFragment(fragment:Fragment){
       if(fragments.size==2){
           fragments.add(fragment)
           notifyDataSetChanged()
       }
    }
    fun removeLocalFragment(){
        if(fragments.size==3){
            fragments.removeLast()
            notifyDataSetChanged()
        }

    }

}